home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: in1.uu.net!pilchuck!news
- From: Meiyu Lin <linm@data-io.com>
- Subject: Re: Problem with Linked Lists
- X-Nntp-Posting-Host: inet-gw
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <312CDFF3.7F4D@data-io.com>
- Sender: news@data-io.com (Usenet news)
- Content-Transfer-Encoding: 7bit
- Organization: Data I/O Corp.
- References: <312A46D7.608A@exis.net>
- Mime-Version: 1.0
- Date: Thu, 22 Feb 1996 21:28:19 GMT
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- Chandler Pitcher wrote:
- >
- > Help!! I'm trying to create a "circular" list that wraps around again from end to
- > beginning, but I am having no luck at setting up a head pointer. The function simply reads names
- > from a file and puts them in the list, I am using the word "Stop" as a sentinel. Once the
- > function is finished, I try to assign the link to the head, but head is following along with
- > the current pointer. How do I keep head and current pointing to the same thing in the
- > beginning, but then separate thru the rest of the function. struct node*, and node* head are
- > assigned in the main.
- >
- > void read_list(node*& head)
- > {
- > head = new node;
- > node *current = head;
- > current = head;
- > stringtype temp;
- > infile>>temp;
- > while (strcmp("Stop", temp))
- > {
- > strcpy(current->name, temp);
- > outfile<<current->name<<" is added to the list."<<endl;
- > infile>>temp;
- > if (!strcmp("Stop", temp))
- > current->link = new node;
- > };
- > current->link = head;
- > return;
- > };
- >
- > Thanks for any help!! I'm really lost at this point!!!
- >
- > Chandler Pitcher |
- > Virginia Beach, Virginia | O A K L A N D R A I D E R S
- > <pitch@exis.net> |Seems you are very lost, why don't you try a book:
- C++ Inside & out by Bruce Eckel, McGrowHill this is a good CPP beginner
- book, and is pretty easy to understand.
-
- Meiyu
-